package com.csinc.generate.core.make.impl.freemarker;

import com.csinc.generate.core.make.impl.MakeProjectMaker;
import com.csinc.generate.core.base.model.DBConnectionEntity;

/**
 * Create By 郭金宝 on 2018/7/25.<br>
 */
public class ApplicationPropertiesMaker extends MakeProjectMaker<ApplicationPropertiesMaker> {

    protected String projectRootPackage;
    protected String dbName;
    protected DBConnectionEntity dbConnectionEntity;

    public ApplicationPropertiesMaker projectRootPackage(String projectRootPackage) {
        this.projectRootPackage = projectRootPackage;
        return this;
    }

    public ApplicationPropertiesMaker dbName(String dbName) {
        this.dbName = dbName;
        return this;
    }

    public ApplicationPropertiesMaker dBConnectionEntityData(DBConnectionEntity dbConnectionEntity) {
        this.dbConnectionEntity = dbConnectionEntity;
        return this;
    }


    @Override
    public ApplicationPropertiesMaker make() {
        data();
        if (ftl == null) {
            this.out("applicationYml.ftl", data);
        } else {
            this.out(ftl, data);
        }
        return this;
    }

    @Override
    public void data() {
        fileName = "application.yml";
        data.put("projectRootPackage", projectRootPackage);
        data.put("dbConnectionEntity", dbConnectionEntity);
        data.put("dbName", dbName);
    }
}